package com.ruoyi.system.configs;


import com.ruoyi.system.interceptor.LoggingInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private LoggingInterceptor loggingInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loggingInterceptor).addPathPatterns("/**") // 拦截所有请求
        .excludePathPatterns(   // 排除静态资源
                "/static/**",
                "/css/**",
                "/js/**",
                "/images/**",
                "/actuator/**",
                "/swagger-ui.html",
                "/swagger-resources/**",
                "/v2/api-docs",
                "/webjars/**",
                "/swagger-ui/**",
                "/doc.html",
                "/favicon.ico",
                "/error"
        );
    }
}
